package com.example.demo;

import com.example.demo.t2.T2_2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeSet;

public class Test2_1 {
    public static void main(String[] args) {
        System.out.println("2_1");

        var list = Arrays.asList("List", "A", "B");
        var gen = new T2_2<String>(list);
        var gen2 = gen.iterator();
        for(var i=0; i< 100; i++){
            System.out.println(gen2.next());
        }

        HashSet<Integer> set1 = new HashSet<>(){
            {
                add(null);
                add(3);
                add(5);
                add(3);
                add(9);
                add(2);
                add(81);
            }
        };

        TreeSet<Integer> set2 = new TreeSet<>(){
            {
//                add(null);
                add(3);
                add(5);
                add(3);
                add(9);
                add(2);
                add(81);
            }
        };

//        System.out.println(set1.stream().map(o -> o.toString()).collect(Collectors.joining(",")));
//
//        System.out.println(set2.stream().map(o -> o.toString()).collect(Collectors.joining(",")));
        System.out.println(set2.lower(5));
        System.out.println(set2.higher(9));
        System.out.println(set2.floor(5));
        System.out.println(set2.ceiling(9));





        ArrayList<String> arr = new ArrayList<>();
        arr.add("123");
        arr.add("1232");
        arr.add("1233");

        ArrayList<String> zarr = new ArrayList<>();
        zarr.add("123");
        zarr.add("1232");
//        zarr.add("1233");

        String[] arr2 = arr.toArray(new String[5]);
        var arr4 = arr.toArray(String[]::new);
        System.out.println(arr2.length);
        arr2[0] = "A";
        arr2[4] = "Z";
        var arr3 = arr.toArray(arr2);
        System.out.println(arr2.length);
        System.out.println(arr3.length);
        System.out.println(arr3[0]);
        System.out.println(arr3[4]);

//        arr.removeAll(zarr);
        arr.retainAll(zarr);
        System.out.println(arr.size());
        System.out.println(arr.get(0));
        System.out.println(arr.get(1));



//        for(var s: gen) {
//            System.out.println(s);
//        }


    }


}


